# FILE: Customer.py
# DESC: encapsulates customer information
#

import MySQLdb

from WebEntity import WebEntity

from infra.logging import logger

class Customer(WebEntity):

	def __init__(self, argv): 
		WebEntity.__init__(self, argv[0], argv[1])
		self.url_ = argv[2]
		self.isActive_ = argv[3]
		
		self.destLoaderRep_ = {}				
		self.destinationsLoaded_ = False

		log = logger.getLogger()
		log.debug("%s = %s" % (self, self.__dict__))
		
		
	def destinationsLoaded(self):
		return self.destinationsLoaded_


	def loadDestinations(self, destLoaders):
		#destinations = {}
		log = logger.getLogger()		
		try:
			for destLoader in destLoaders:
				self.destLoaderRep_[destLoader.getDestinationType()] = destLoader
				destLoader.load()
							
			'''
			self.geoPlacemarkNodeLoader_.process(geonameWebDocNodeMap, adminDivisionNodeMap)			
			self.adminDivisionNodeLoader_.process(countryNodeMap)
			self.countryNodeLoader_.process(continentNodeMap)
			'''
			
			self.destinationsLoaded_ = True
		
		except MySQLdb:
			raise

		except:
			log.error("An exception occured")
			raise
		

	def getDestinationLoader(self, destType):
		log = logger.getLogger()
		try:
			return self.destLoaderRep_[destType]
		except KeyError:
			log.error("DestinationNodeLoader for destType = %s not found." % destType)
			raise
		


	def getUrl(self):
		return self.url_


	def isActive(self):
		return self.isActive_


	def toString(self):
		return self.utf8Name_


	def dump(self):
		return self.__dict__
